package com.itheima.test.UDP.broadcast;

import java.io.IOException;
import java.net.*;

public class Client {//广播代码实现

    public static void main(String[] args) throws IOException {
        //创建码头,包裹
        DatagramSocket socket = new DatagramSocket();
        InetAddress address = InetAddress.getByName("255.255.255.255");
        byte[] bytes = "Hello,广播".getBytes();
        DatagramPacket packet = new DatagramPacket(bytes, bytes.length, address, 10000);
        //发送数据并时释放资源
        socket.send(packet);
        socket.close();
    }
}
